package com.fortune.service.impl;

import com.fortune.dao.DriverOrderDao;
import com.fortune.dto.in.driverOrder.DriverOrderPayedDto;
import com.fortune.entity.DriverOrderInfoDetailGy;
import com.fortune.service.DriverOrderService;
import com.fortune.vo.driverOrder.DriverOrderDetail;
import com.fortune.vo.driverOrder.DriverPaymentInfor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class DriverOrderServiceImpl implements DriverOrderService {
    @Autowired
    private DriverOrderDao driverOrderDao;

    /**
     * 查询配送清单列表
     * @param did
     * @param deliveryUser
     * @return
     */
    @Override
    public List<DriverOrderInfoDetailGy> findListDriverOrderInfoDetailGy(String did, String deliveryUser) {
        List<DriverOrderInfoDetailGy> findListDriverOrderInfoDetailGy = driverOrderDao.findListDriverOrderInfoDetailGy(did, deliveryUser);
        return findListDriverOrderInfoDetailGy;
    }

    /**
     * 查询订单详情
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public DriverOrderDetail findDriverOrderDetail(String did, String clientId, String orderId) {
        DriverOrderDetail findDriverOrderDetail = driverOrderDao.findDriverOrderDetail(did, clientId, orderId);
        return findDriverOrderDetail;
    }

    /**
     * 查询支付信息
     * @param clientId
     * @return
     */
    @Override
    public DriverPaymentInfor findDriverPaymentInfor(String clientId) {
        DriverPaymentInfor findDriverPaymentInfor = driverOrderDao.findDriverPaymentInfor(clientId);
        return findDriverPaymentInfor;
    }

    /**
     * 修改状态
     * @param did
     * @param payDto
     * @return
     */
    @Override
    public int editDriverPaymentStaus(String did, DriverOrderPayedDto payDto) {
        if(payDto.getSerialNumber() == null){
            int editDriverPaymentNOStaus = driverOrderDao.editDriverPaymentNOStaus(did, payDto);
            return editDriverPaymentNOStaus;
        }
        int editDriverPaymentStaus = driverOrderDao.editDriverPaymentStaus(did, payDto);
        return editDriverPaymentStaus;
    }
    /**
     * 修改回收箱数和金额
     * @param clientId
     * @param orderId
     * @param no
     * @return
     */
    @Override
    public int editOrderDelivery(String clientId, String orderId, String no, float backBoxNum, BigDecimal dprice) {
        int editOrderDelivery = driverOrderDao.editOrderDelivery(clientId, orderId, no, backBoxNum, dprice);
        return editOrderDelivery;
    }
}
